﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 2.6
// Code is generated on: Tuesday, June 23, 2009 10:22:09 PM
// Code is generated using templates: SD.TemplateBindings.Linq
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using SD.LLBLGen.Pro.LinqSupportClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

using OrmSmackdown.LLBLGen;
using OrmSmackdown.LLBLGen.DaoClasses;
using OrmSmackdown.LLBLGen.EntityClasses;
using OrmSmackdown.LLBLGen.FactoryClasses;
using OrmSmackdown.LLBLGen.HelperClasses;
using OrmSmackdown.LLBLGen.RelationClasses;

namespace OrmSmackdown.LLBLGen.Linq
{
	/// <summary>Meta-data class for the construction of Linq queries which are to be executed using LLBLGen Pro code.</summary>
	public partial class LinqMetaData : ILinqMetaData
	{
		#region Class Member Declarations
		private ITransaction _transactionToUse;
		private FunctionMappingStore _customFunctionMappings;
		private Context _contextToUse;
		#endregion
		
		/// <summary>CTor. Using this ctor will leave the transaction object to use empty. This is ok if you're not executing queries created with this
		/// meta data inside a transaction. If you're executing the queries created with this meta-data inside a transaction, either set the Transaction property
		/// on the IQueryable.Provider instance of the created LLBLGenProQuery object prior to execution or use the ctor which accepts a transaction object.</summary>
		public LinqMetaData() : this(null, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse) : this(transactionToUse, null)
		{
		}
		
		/// <summary>CTor. If you're executing the queries created with this meta-data inside a transaction, pass a live ITransaction object to this ctor.</summary>
		/// <param name="transactionToUse">the transaction to use in queries created with this meta-data</param>
		/// <param name="customFunctionMappings">The custom function mappings to use. These take higher precedence than the ones in the DQE to use.</param>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public LinqMetaData(ITransaction transactionToUse, FunctionMappingStore customFunctionMappings)
		{
			_transactionToUse = transactionToUse;
			_customFunctionMappings = customFunctionMappings;
		}
		
		/// <summary>returns the datasource to use in a Linq query for the entity type specified</summary>
		/// <param name="typeOfEntity">the type of the entity to get the datasource for</param>
		/// <returns>the requested datasource</returns>
		public IDataSource GetQueryableForEntity(int typeOfEntity)
		{
			IDataSource toReturn = null;
			switch((OrmSmackdown.LLBLGen.EntityType)typeOfEntity)
			{
				case OrmSmackdown.LLBLGen.EntityType.AddressesEntity:
					toReturn = this.Addresses;
					break;
				case OrmSmackdown.LLBLGen.EntityType.CompaniesEntity:
					toReturn = this.Companies;
					break;
				case OrmSmackdown.LLBLGen.EntityType.ContactEntity:
					toReturn = this.Contact;
					break;
				case OrmSmackdown.LLBLGen.EntityType.PeopleEntity:
					toReturn = this.People;
					break;
				case OrmSmackdown.LLBLGen.EntityType.PortalPeopleXrefEntity:
					toReturn = this.PortalPeopleXref;
					break;
				case OrmSmackdown.LLBLGen.EntityType.PortalsEntity:
					toReturn = this.Portals;
					break;
				case OrmSmackdown.LLBLGen.EntityType.RolesEntity:
					toReturn = this.Roles;
					break;
				case OrmSmackdown.LLBLGen.EntityType.UserEntity:
					toReturn = this.User;
					break;
				default:
					toReturn = null;
					break;
			}
			return toReturn;
		}

		/// <summary>returns the datasource to use in a Linq query when targeting AddressesEntity instances in the database.</summary>
		public DataSource<AddressesEntity> Addresses
		{
			get { return new DataSource<AddressesEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting CompaniesEntity instances in the database.</summary>
		public DataSource<CompaniesEntity> Companies
		{
			get { return new DataSource<CompaniesEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting ContactEntity instances in the database.</summary>
		public DataSource<ContactEntity> Contact
		{
			get { return new DataSource<ContactEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting PeopleEntity instances in the database.</summary>
		public DataSource<PeopleEntity> People
		{
			get { return new DataSource<PeopleEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting PortalPeopleXrefEntity instances in the database.</summary>
		public DataSource<PortalPeopleXrefEntity> PortalPeopleXref
		{
			get { return new DataSource<PortalPeopleXrefEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting PortalsEntity instances in the database.</summary>
		public DataSource<PortalsEntity> Portals
		{
			get { return new DataSource<PortalsEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting RolesEntity instances in the database.</summary>
		public DataSource<RolesEntity> Roles
		{
			get { return new DataSource<RolesEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		/// <summary>returns the datasource to use in a Linq query when targeting UserEntity instances in the database.</summary>
		public DataSource<UserEntity> User
		{
			get { return new DataSource<UserEntity>(_transactionToUse, new ElementCreator(), _customFunctionMappings, _contextToUse); }
		}
		
		#region Class Property Declarations
		/// <summary> Gets / sets the ITransaction to use for the queries created with this meta data object.</summary>
		/// <remarks> Be aware that the ITransaction object set via this property is kept alive by the LLBLGenProQuery objects created with this meta data
		/// till they go out of scope.</remarks>
		public ITransaction TransactionToUse
		{
			get { return _transactionToUse;}
			set { _transactionToUse = value;}
		}

		/// <summary>Gets or sets the custom function mappings to use. These take higher precedence than the ones in the DQE to use</summary>
		public FunctionMappingStore CustomFunctionMappings
		{
			get { return _customFunctionMappings; }
			set { _customFunctionMappings = value; }
		}
		
		/// <summary>Gets or sets the Context instance to use for entity fetches.</summary>
		public Context ContextToUse
		{
			get { return _contextToUse;}
			set { _contextToUse = value;}
		}
		#endregion
	}
}